package com.tarena.lbs.basic.web.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tarena.lbs.pojo.basic.dos.StoreDO;
import com.tarena.lbs.pojo.basic.po.StorePO;
import com.tarena.lbs.pojo.basic.query.AreaStoreQuery;
import com.tarena.lbs.pojo.basic.query.StoreQuery;
import org.apache.ibatis.annotations.*;
import java.util.List;

@Mapper
public interface StoreMapper extends BaseMapper<StorePO> {
    @Select("SELECT id, business_id, store_name, store_phone, store_head_name, store_head_phone, store_location, store_longitude, store_latitude, store_images_id, store_logo, store_introduction, sort, trade_time, store_status, create_time, update_time, city_id, province_id, area_id FROM lbs_store")
    List<StoreDO> selectStoresByPage(StoreQuery query);

    @Insert("INSERT INTO lbs_store (business_id, store_name, store_phone, store_head_name, store_head_phone, \n" +
            "area_id, city_id, province_id, store_location, store_longitude, store_latitude, \n" +
            "store_images_id, store_logo, store_introduction, sort, trade_time, store_status, \n" +
            "create_time, update_time)\n" +
            "VALUES (\n" +
            "#{businessId}, #{storeName}, #{storePhone}, #{storeHeadName}, #{storeHeadPhone},\n" +
            "#{areaId}, #{cityId}, #{provinceId}, #{storeLocation}, #{storeLongitude}, #{storeLatitude},\n" +
            "#{storeImagesId}, #{storeLogo}, #{storeIntroduction}, #{sort}, #{tradeTime}, #{storeStatus},\n" +
            "#{createTime}, #{updateTime}\n" +
            ");")
    @Options(useGeneratedKeys = true,keyColumn = "id",keyProperty = "id")
    void insertDb(StoreDO storeDO);

    List<StoreDO> selectStoresByAreasAndBusiness(@Param("id") Integer id,@Param("query") AreaStoreQuery query);
}
